/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.store;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.model.SelectItem;
import oracle.jdbc.OracleTypes;
import queenb.net.datacontrol.DataStatement;
import queenb.net.datacontrol.Param;
import queenb.net.entitybean.A000;
import queenb.web.util.PackageContants;

/**
 *
 * @author VANANH
 */
public class A000Store extends A000 {

    public List<A000> getListCityALL(int pn750,String pvLOGIN) throws SQLException, InstantiationException, IllegalAccessException {
        DataStatement dataStatement = new DataStatement(PackageContants.LIST_A000ALL, OracleTypes.CURSOR, new Param[]{
                    
                    new Param(OracleTypes.INTEGER, pn750),
                new Param(OracleTypes.CHAR, pvLOGIN)
                });

        return super.find(dataStatement, A000.class);
    }

    public List<A000> getListCity(String pnA000, int pn750) throws SQLException, InstantiationException, IllegalAccessException {
        DataStatement dataStatement = new DataStatement(PackageContants.LIST_A000, OracleTypes.CURSOR, new Param[]{
                    new Param(OracleTypes.CHAR, pnA000),
                    new Param(OracleTypes.INTEGER, pn750)
                });

        return super.find(dataStatement, A000.class);
    }

    public List<SelectItem> getCitySelect(String pnA000, int pn750) throws SQLException, InstantiationException, IllegalAccessException {
        List<A000> listA000 = getListCity(pnA000, pn750);
        List<SelectItem> listSelect = new ArrayList<SelectItem>();
        for (int i = 0; i < listA000.size(); i++) {
            A000 a000 = listA000.get(i);
            listSelect.add(new SelectItem(a000.getPa000(), a000.getAv001()));
        }

        return listSelect;
    }

    public int updateA000(int pnPA000, String pvAV001, String pvAV002, String pvAV003, int pnFA000, String pvLOGIN) {
        try {
            DataStatement updateStatement = new DataStatement(PackageContants.UPDATE_A000, OracleTypes.INTEGER, new Param[]{
                        new Param(OracleTypes.INTEGER, pnPA000),
                        new Param(OracleTypes.CHAR, pvAV001),
                        new Param(OracleTypes.CHAR, pvAV002),
                        new Param(OracleTypes.CHAR, pvAV003),
                        new Param(OracleTypes.INTEGER, pnFA000),
                        new Param(OracleTypes.CHAR, pvLOGIN)});
            return super.update(updateStatement, A000.class);
        } catch (SQLException ex) {

            return 0;
        }

    }

    public List<A000> findAllA000ForCombo(int pnFH000, int pnFH200, int pnFN750,int pnFK100, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_A000, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFN750),
                        new Param(OracleTypes.INTEGER, pnFK100),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, A000.class);
        } catch (SQLException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    // Hàm dùng select trong tourbean
    public List<A000> findAllA000Forcountry(int pnFN750, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_A000_country, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFN750),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, A000.class);
        } catch (SQLException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    // Hamf lay nha cung cap tu dich vu va tinh thanh
    public List<A000> findAllA000Forsupplier(int pnFH000, int pnFH200, int pnFA000, int pnFV200, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_A000_country_service, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFA000),
                        new Param(OracleTypes.INTEGER, pnFV200),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, A000.class);
        } catch (SQLException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    
     public int deleteA000(int pnPA000, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.DELETE_A000, OracleTypes.INTEGER, new Param[]{
                        new Param(OracleTypes.INTEGER, pnPA000),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.update(dataStatement, A000.class);
        } catch (SQLException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }

    }
     // danh sach cac tinh thanh - filter Dich vu
    public List<A000> getListCityByCountryIdDV(int pnFH000, int pnFH200, int pnFN750, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_A000_DV, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFN750),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, A000.class);
        } catch (SQLException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    
    //lay dang sach diem bat dau - ket thuc cho form SP tour
    public List<A000> getListCityAndCountry(int pnFH000, int pnFH200, int pnFN750, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_A000_SP, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFN750),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, A000.class);
        } catch (SQLException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(A000Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
}
